using System;
using System.Collections.Generic;
using System.Data;
using MallInteractiveMap.ClientDataHandler;
using MallInteractiveMap.Common;
using MallInteractiveMap.DTO;
using System.Linq;

namespace MallInteractiveMap.CMSWebClient.Presenter
{
	public class ShopPresenter
	{
		public ShopPresenter()
		{
		}
		public List<DTOShop> GetShops()
		{
			string error = string.Empty;
			List<DTOShop>shop= ClientData.GetShop(new QueryParamList(), ref error);
			if (!string.IsNullOrEmpty(error))
			{

			}
			return shop;
		}
		public List<DTOShop> GetShops(int Id)
		{
			string error = string.Empty;
			QueryParamList param = new QueryParamList();
			param.Add(new QueryParamObj() { ParamName = "Id", DBType = DbType.Int32 , ParamValue = Id});
			List<DTOShop>shop= ClientData.GetShop(param, ref error);
			if (!string.IsNullOrEmpty(error))
			{

			}
			return shop;
		}
        public List<DTOShopPhotos> GetShopPhotos(int shopId)
        {
            string error = string.Empty;
            QueryParamList param = new QueryParamList();
            param.Add(new QueryParamObj() { ParamName = "ShopId", DBType = DbType.Int32, ParamValue = shopId });
            List<DTOShopPhotos> photos = ClientData.GetShopPhoto(param, ref error);
            if (!string.IsNullOrEmpty(error))
            {

            }
            return photos;
        }

        public DTOShopPhotos GetPhotosById(int Id)
        {
            string error = string.Empty;
            QueryParamList param = new QueryParamList();
            param.Add(new QueryParamObj() { ParamName = "Id", DBType = DbType.Int32, ParamValue = Id });
            List<DTOShopPhotos> shopphotos = ClientData.GetShopPhoto(param, ref error);
            if (!string.IsNullOrEmpty(error))
            {

            }
            return shopphotos.FirstOrDefault();
        }

		public bool SetData(DTOShop oShop)
		{
			string error = string.Empty;
		
			bool isSuccess = ClientData.SaveShop(oShop, ref error);
			return string.IsNullOrEmpty(error) & isSuccess;
		}

		public bool Delete(int Id)
		{
			string error = string.Empty;
			QueryParamList param = new QueryParamList();
			param.Add(new QueryParamObj() { ParamName = "Id", DBType = DbType.Int32 , ParamValue = Id});
			bool isSuccess = ClientData.SetData(param, "DELETEShop",  ref error);
			return string.IsNullOrEmpty(error) & isSuccess;
		}

	    public bool DeletePhoto(int imgId)
        {
            string error = string.Empty;
            QueryParamList param = new QueryParamList();
            param.Add(new QueryParamObj() { ParamName = "Id", DBType = DbType.Int32, ParamValue = imgId });
            bool isSuccess = ClientData.SetData(param, "DELETEShopPhotos", ref error);
            return string.IsNullOrEmpty(error) & isSuccess;
        }
	}
}
